package demo;

import java.util.Collection;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;



@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring/spring-config.xml")
public class DemoTest {
	
	private Log logger = LogFactory.getLog(getClass());
	
	@Autowired
	private SomeService service;
	
	
	@Ignore
	@Test
	public void testUserCache() {
		logger.info("first query...");
		User findUser = service.findUser(11L);
		logger.info("2nd query...");
		User findUser2 = service.findUser(11L);
		
//		logger.info("add user");
//		User user = new User();
//		user.setName("小刘");
//		user.setPhone("1352344");
//		service.addUser(user);
		
		logger.info("update user");
		User user1 = new User();
		user1.setName("小马");
		user1.setPhone("1234");
		user1.setId(11L);
		
		service.update(user1);
		
		logger.info("3rd query...");
		User findUser3 = service.findUser(1L);
		
		logger.info("4th query...");
		User findUser4 = service.findUser(1L);
		
	}
//	@Test
//	public void testFindUser() {
//		logger.info("first query...");
//		User findUser = service.findUser();
//		logger.info("2nd query...");
//		User findUser2 = service.findUser();
//		
//	}

	@Test
	public void testFindAllUsers() {
		
		logger.info("first query for collection...");
		Collection<User> findAllUsers = service.findAllUsers();
		logger.info("second query for collection...");
		Collection<User> findAllUsers2 = service.findAllUsers();
	}
//
//	@Test
//	public void testAddUser() {
//		User user = new User();
//		service.addUser(user);
//		
//	}

}
